<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户关系管理及报关单统计系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
	.ui-datepicker table {
		border: 0;
	}
	.ui-autocomplete-loading { 
		background: white url('images/ui-anim_basic_16x16.gif') left center no-repeat; 
	}
	.ui-autocomplete,.ui-menu-item .ui-corner-all {
			border-radius: 0;
	}
	thead th{
		text-align:center;
		background:#e0e0e0;
	}
	tbody th[scope="row"],tbody th.sub{
		text-align:center;
	}
	input,select{
		border:1px solid #888888;
	}
	input:hover,input:active,select:hover,select:active{
		border:1px solid #aa6666
	}
	input[type=text]{
		padding:2px;
		margin:1px 0;
	}
	#pagebar{
		float:right;
	}
	#search_bar{
		border-width:1px 0;
	}
	#search_bar td{
		padding:1px;
		border-width:0;
	}
	#search_bar tr:hover td{
		background:#fff;
	}
	.bt_button{
    cursor: pointer;
    overflow: visible;
    width: auto;
    background: url("lib/yaml/screen/images/button_gray.png") repeat-x scroll left top #454545;
    border-color: #DDDDDD #444444 #444444 #DDDDDD;
    border-style: solid;
    border-width: 1px;
    color: #000000;
    padding: 5px 1em;	
	}
	.bt_button:hover,.bt_button:active,.bt_button:focus{
    background: none repeat-x scroll left top #555555;
    border-color: #444444 #DDDDDD #DDDDDD #444444;
    color: #ffffff;
	}
	#page_go,#print_search,.bt_act{
		padding:0;
	}
	.chk{
		background-color:#d0d0d0;
	}
	#diaglog_print{
		display:none;
	}
	#lb_search{
		width:5em;
	}
	#bts_search{
		width:11.9em;
		text-align:right;
	}
	#adv_search{
		display:none;
	}
	
/* Tag cloud */
	
    #tags {  
      text-align:center; 
			padding:10px 0;  
			margin:5px 0;
      overflow:auto; 
    }  
    #tags ul { margin:0; padding:0; }  
    #tags ul li {  
      list-style-type:none; float:left; margin:-1px 10px; 
    }  
    #tags ul li a { text-decoration:none;  line-height:1.1em;}  
    #tags ul li a:hover { text-decoration:none; border:1px solid #aa6666}  	
/* // Tag cloud */


/* 详细报关单列表 */
	.cdtr:hover td,th{
		background-color:white;
	}
	.cdtd{
		padding:0;
	}
	.cdtr .cdtd table{
		margin:0;
	}
	.tac{
		text-align:center;
	}
/* // 详细报关单列表 */
/* select class */

		.sel{
			color:red;
		}
		.unsel{
			color:black;
		}
	
/* // select class */


/* // 岗位颜色 */
/* select class */

		.post_2{
			background-color:hotpink;
		}
		.post_3{
			background-color:yellow;
		}
		.success_0{
			background-color:darkgray;
		}
		.success_1{
			background-color:lightgreen;
		}
	
/* // select class */



</style>

<script type="text/javascript">
	$(function() {
		$.ajaxSetup ({
			cache: false, //关闭AJAX相应的缓存
			beforeSend:function() {
				$("#search_bar .ui-widget").addClass( "ui-autocomplete-loading" );
				$("#bt_search").attr("disabled",true);
			},
			complete:function() {
				$("#search_bar .ui-widget").removeClass( "ui-autocomplete-loading" );
				$("#bt_search").attr("disabled",false);
			}
		});

		$(".datepicker").datepicker();
		var p=1;
		function vi(p){
			$.get("search_main.asp?page="+p+"&"+$("#fm_search").serialize(),function(data){	//用ajax的get方式提交
				$("#search_main").html(data);

				$("#pagebar a").click(function(e){	//对分页栏中的a元素进行操作
					e.preventDefault();	//阻止a的原先事件
					vi($(this).attr("id"));	//根据获取的页码值调用显示页面函数
				});
				$("#page_go").click(function(e){	//对分页栏中的input元素进行操作
					e.preventDefault();
					if (isNaN($("#page_val").val())||$.trim($("#page_val").val())==""){	//判断输入的是否是数字
						alert("输入的页码错误，请输入正确页码！");
						$("#page_val").select();
						return false;	//页码值不是数字则退出；
					}
					vi($("#page_val").val());
				});
				var chk=$(".checkid");
				$("#checkall").click(function(){
					chk.prop("checked",$(this).prop("checked"));	//根据全选的checkbox状态来填充单个checkbox状态
					$(this).prop("checked") ? chk.closest("tr").addClass("chk") : chk.closest("tr").removeClass("chk")	//判断是否全部选中，选中则增加chk样式，没选中则删除chk样式，不能用toggleClass方法，由于下面单个checkbox会改变全选的checkbox状态
				});
				chk.click(function(){
					if(!$(this).prop("checked")) $("#checkall").prop("checked",false);	//如果当前checkbox状态为未选中则全选的checkbox也设置为未选中
					$(this).closest("tr").toggleClass("chk");	//单个切换当前checkbox存在的tr的chk样式
				});
				
				$("#bt_forget").click(function(){
					$chks=$("#search_main input:checkbox.checkid:checked");
					if(confirm("要忽略这 "+$chks.length+" 个客户吗？")){
						var aChk=new Array();
						$chks.each(function(){
							aChk.push($(this).val());
						});
						$.post("json_forget.asp",{"chks":aChk.join(),"act":$(this).val()},function(data){
							if(data.bStatus){
								vi($("#page_val").val());
							}else{
								alert(data.sInfo);
							}
						},"json");
					}
				});
				$("#bt_dispatch").click(function(){
					if($("#empe").val()==""){
						alert("请选择要派单的组员！");
						return 0;
					}
					$chks=$("#search_main input:checkbox.checkid:checked");
					if(confirm("要把这 "+$chks.length+" 个客户派给 "+$("#empe optgroup option:selected").text()+" 吗？")){
						var aChk=new Array();
						$chks.each(function(){
							aChk.push($(this).val());
						});
						$.post("json_dispatch.asp",{"chks":aChk.join(),"accepter":$("#empe").val()},function(data){
							if(data.bStatus){
								vi($("#page_val").val());
							}else{
								alert(data.sInfo);
							}
						},"json");
					}
				});
				
			});

		}
		
		$("#visit").change(function(){
			if($(this).val()==1){
				$("#visit_ksrq").prop("disabled",false);
				$("#visit_jsrq").prop("disabled",false);
			}else{
				$("#visit_ksrq").prop("disabled",true).val("");
				$("#visit_jsrq").prop("disabled",true).val("");
			}
		});
		$("#bt_search").click(function(){
			var start_time = new Date().getTime();
			vi(p);
			var end_time = new Date().getTime();
			$("#show_runtime").html(end_time-start_time);
		});
		$("#show_adv").click(function(){
			$("#adv_search").toggle();
		});
		$("#search_bar select").change(function(){
			//console.log($(this).get(0).selectedIndex);
			if($(this).get(0).selectedIndex==0){
				$(this).removeClass("sel");
			}else{
				$(this).addClass("sel")
					.find("*").addClass("unsel")
					.parents("select").find("option[value='"+$(this).val()+"']").removeClass("unsel")
					.parents("optgroup").removeClass("unsel");
			}
		});
		$("#search_bar input[type=reset]").click(function(){
			$("#search_bar select").removeClass("sel")
				.find("*").removeClass("unsel");
		});
		
		// tag cloud
		
		$.getJSON("json_tagcloud.asp",function(data){
			function fColorRdm(){
				return Math.floor(Math.random()*220);
			}
			
			
			
			function fColor(){
				//return "#"+fColorRdm().toString(16)+fColorRdm().toString(16)+fColorRdm().toString(16);
				var str = "0123456789abcdef";
				var t = "#";
				for(var j=0;j<6;j++){
					t = t + str.charAt(Math.random()*str.length);
				}
				return t;
			}
		
			function fMinFreq(tags){
				var iMin,iMax;
				iMin=iMax=tags[0].freq;
				$.each(tags, function(i, item) {
					if(iMin>item.freq){
						iMin=item.freq;
					}
					if(iMax<item.freq){
						iMax=item.freq;
					}
				});
				return new Array(iMin,iMax);
			}
			
			iMinFreq=fMinFreq(data.tags)[0];
			iMaxFreq=fMinFreq(data.tags)[1];
			
			//create list for tag links
			$("<ul>").appendTo("#tags");
			//create tags
			$.each(data.tags, function(i, val) {
				
				//create item
				var li = $("<li>");

				//regex = new RegExp("有限公司");
				
				tag=val.tag;
				tag=tag.replace(/股份有限公司/g, "");
				tag=tag.replace(/集团有限公司/g, "");
				tag=tag.replace(/有限公司/g, "");
				tag=tag.replace(/宁波市/g, "");
				tag=tag.replace(/宁波/g, "");
				tag=tag.replace(/台州市/g, "");
				tag=tag.replace(/台州/g, "");
				tag=tag.replace(/温州市/g, "");
				tag=tag.replace(/温州/g, "");
				tag=tag.replace(/鄞州区/g, "");
				tag=tag.replace(/鄞州/g, "");
				tag=tag.replace(/浙江省/g, "");
				tag=tag.replace(/浙江/g, "");
				
				
				//create link
				$("<a>").text(tag)
								.attr({title:"共 " + val.freq + " 单", href: val.tag })
								.css({"font-size": Math.log( val.freq ) / Math.log( iMinFreq ) + "em" , "color" : fColor()})
								.tooltip()
								.appendTo(li);
				
				
				
				
				//add to list
				li.appendTo("#tags>ul");
				//li.children().css("fontSize", (val.freq / 10 < 1) ? val.freq / 10 + 1 + "em" : val.freq / 10 + "em");
				//li.children().css({"font-size": Math.log( val.freq ) / Math.log( iMinFreq ) + "em","color":fColor()});
			});
		});
		
		$("#tags ul li a").live("click",function(e){
			e.preventDefault();
			//alert($(this).html());
			$("#tx_search").val($(this).attr("href"));
			$("#bt_search").trigger("click");
		});
		
		// tag cloud

		
		
		
		$("#search_main a.tbl_cd").live('click',function(e){	//对分页栏中的a元素进行操作
			e.preventDefault();	//阻止a的原先事件
			$tr=$(this).parent().parent();
			tdnum=$tr.find('td,th').length;
			s=$(this).attr('show');
			if(s=='hidden'){
				$tr.next().show();
				$(this).attr('show','true');
			}
			if(s=='true'){
				$tr.next().hide();
				$(this).attr('show','hidden');
			}else if(s=='false'){
				$.get("cds.asp?"+$(this).attr('href'),function(data){	//用ajax的get方式提交
					$tr.after("<tr class='cdtr'><td colspan='"+tdnum+"' class='cdtd'>"+data+"</td></tr>");
				});
				$(this).attr('show','true');
			}
		});		
		
		
		
		
		
		
		
	});
</script>	
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
if not CheckFlag(session("aaPostFlag"),1) then call JumpErrorPage(2)
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">

<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
	<div id="col3" role="main">
		<div id="col3_content" class="clearfix">
			<form id="fm_search" name="fm_search">
				<table id="search_bar" class="full">
					<tr>
						<td id="lb_search"><label for="tx_search">查询内容：</label></td>
						<td>
							<div>
								<input id="tx_search" name="tx_search" type="text" />
								<select id="dept" name="dept">
									<option value="">选择组</option>
									<%
										Set rs_dept = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT * FROM crm_dept where id>0 "
										if session("iDept")<>0 then sql=sql&" and id="&session("iDept") 
										sql=sql&" order by id"
										rs_dept.Open sql,conn,1,1
										do while not rs_dept.eof
									%>
									<option value="<%=rs_dept("id")%>"><%=rs_dept("dept")%></option>
									<%
											rs_dept.movenext
										loop
										rs_dept.close
										set rs_dept=nothing
									%>
								</select>
								<select id="empe" name="empe">
									<option value="">选择组员</option>
									<%
										Set rs_empe = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT crm_empe.*,crm_dept.dept as deptname FROM crm_empe,crm_dept where crm_empe.dept=crm_dept.id and crm_dept.id>0 "
										if session("iDept")<>0 then sql=sql&" and crm_dept.id="&session("iDept")
										if session("bCaptain")<>1 then sql=sql&" and crm_empe.id="&session("iId")
										sql=sql&" order by crm_dept.id asc,crm_empe.id asc"
										rs_empe.Open sql,conn,1,1
										dim empe_option,deptname
										empe_option=""
										deptname=""
										
										do while not rs_empe.eof
											if rs_empe("deptname")<>deptname then
												if deptname<>"" then empe_option=empe_option&"</optgroup>"
												deptname=rs_empe("deptname")
												empe_option=empe_option&"<optgroup label='"&deptname&"'>"
											end if
											empe_option=empe_option&"<option value='"&rs_empe("id")&"'>"&rs_empe("empe")
											if rs_empe("captain") then empe_option=empe_option&"(组长)"
											empe_option=empe_option&"</option>"
											rs_empe.movenext
										loop
										rs_empe.close
										set rs_empe=nothing
										response.write empe_option
									%>
								</select>
								<select id="success" name="success">
									<option value="">是否成功</option>
									<option value="0">失败</option>
									<option value="1">成功</option>
								</select>
								<select id="post" name="post">
									<option value="">选择岗位</option>
									<%
										Set rs_post = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT * FROM crm_post where "
										if session("iDept")<>0 then sql=sql&" id>1 " else sql=sql&" id>0 "
										sql=sql&" order by id"
										rs_post.Open sql,conn,1,1
										do while not rs_post.eof
									%>
									<option value="<%=rs_post("id")%>"><%=rs_post("post")%></option>
									<%
											rs_post.movenext
										loop
										rs_post.close
										set rs_post=nothing
									%>
								</select>
								<select id="location" name="location">
									<option value="">客户地区</option>
									<%
										Set rs_location = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT * FROM crm_location order by id"
										rs_location.Open sql,conn,1,1
										do while not rs_location.eof
									%>
									<option value="<%=rs_location("id")%>"><%=rs_location("location")%></option>
									<%
											rs_location.movenext
										loop
										rs_location.close
										set rs_location=nothing
									%>
								</select>
								<select id="forget" name="forget">
									<option value="0">正常</option>
									<option value="1">忽略</option>
									<option value="">全部</option>
								</select>
								<select id="search_count" name="search_count">
									<option value="100">100条</option>
									<option value="1000">1000条</option>
									<option value="10000">10000条</option>
									<option value="">全部</option>
								</select>
								<select id="orderby" name="orderby">
									<option value="boxs">按箱量倒序</option>
									<option value="crm_update">按更新倒序</option>
								</select>
								<a id="show_adv" href="#">高级</a>
							</div>
							<div id="adv_search">
								<select id="touch" name="touch">
									<option value="">是否联系过</option>
									<option value="0">未联系过</option>
									<option value="1">已联系过</option>
								</select>
								<select id="assist" name="assist">
									<option value="">是否需要协助</option>
									<option value="0">无需协助</option>
									<option value="1">需要协助</option>
								</select>
								<select id="visit" name="visit">
									<option value="">是否计划拜访</option>
									<option value="0">无需拜访</option>
									<option value="1">计划拜访</option>
								</select>
								出差日期
								<input name="visit_ksrq" id="visit_ksrq" class="datepicker" type="text" size="10" maxlength="10" disabled="disabled" />-<input name="visit_jsrq" id="visit_jsrq" class="datepicker" type="text" size="10" maxlength="10" disabled="disabled" />
								<select id="source" name="source">
									<option value="">主要工厂</option>
									<%
										Set rs_source = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT * FROM source order by source"
										rs_source.Open sql,conn,1,1
										do while not rs_source.eof
									%>
									<option value="<%=rs_source("source")%>"><%=rs_source("source")%></option>
									<%
											rs_source.movenext
										loop
										rs_source.close
										set rs_source=nothing
									%>
								</select>
								<select id="target" name="target">
									<option value="">主要出口方向</option>
									<%
										Set rs_country = Server.CreateObject("ADODB.Recordset")
										sql = "SELECT * FROM country order by country"
										rs_country.Open sql,conn,1,1
										do while not rs_country.eof
									%>
									<option value="<%=rs_country("country")%>"><%=rs_country("country")%></option>
									<%
											rs_country.movenext
										loop
										rs_country.close
										set rs_country=nothing
									%>
								</select>
							</div>
						</td>
						<td id="bts_search">
							<div class="ui-widget">
							<input id="bt_search" class="bt_button" name="bt_submit" type="button" value="搜索" />
							<input class="bt_button" type="reset" value="重置" />
							</div>
						</td>
					</tr>
				</table>
			</form>
			<div id="search_main">
				<div id="tags"></div>			
			</div>
		</div>
	</div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

